package com.yunhe.controller;

import com.yunhe.common.Result;
import com.yunhe.entity.Menu;
import com.yunhe.service.MenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
/**
 * 控制层类：MenuController,调用业务层
 */
@Controller
@RequestMapping("/menu")
@Api(value = "/menu",description = "菜单信息管理")
public class MenuController {
    @Autowired
    MenuService menuService;
    /**
     * 要根据不同的用户身份获取菜单列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "获取所有菜单信息")
    public Result list(@RequestParam String roleid){
        List<Menu> list = menuService.lambdaQuery().like(Menu::getMenuright, roleid).list();
        return Result.success(list);
    }

    // @GetMapping("/list/{roleid}")
    // @ResponseBody
    // public List<Menu> list(@PathVariable String roleid){
    //     List<Menu> list = menuService.lambdaQuery().like(Menu::getMenuright, roleid).list();
    //     return list;
    // }

}